package com.qsbg.controller;

import com.qsbg.entity.vo.DynamicPageVo;
import com.qsbg.entity.vo.ResultVo;
import com.qsbg.service.DynamicService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/dynamic")
public class DynamicController {
    @Resource
    private DynamicService dynamicService;


    /**
     * 三表联表分页查询
     * @param dynamicPageVo
     * @return
     */
    @PostMapping("/getdynamiclist")
    public ResultVo getUsers(@RequestBody DynamicPageVo dynamicPageVo){

        return dynamicService.getDynamics(dynamicPageVo);
    }

    /**
     * 根据id查询活动
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ResultVo getDynamic(@PathVariable Integer id){
        return dynamicService.getDynamic(id);
    }


    @DeleteMapping("/{id}")
    public ResultVo removeDynamic(@PathVariable Integer id){
        try{
            dynamicService.removeById(id);
            return ResultVo.ok();
        }catch (Exception e){
            e.printStackTrace();
            return ResultVo.fail("删除出错");
        }
    }

}



